--------------------------------------------------
-- Level code
-- Created 23:19 2021-3-10
--------------------------------------------------

-- Run code on level start
function onStart()
    --Your code here
end

-- Run code every frame (~1/65 second)
-- (code will be executed before game logic will be processed)
function onTick()
    for key, NPC in pairs(NPC.get(16,-1)) do
        NPC.id = 97
        NPC.speedY = -3.5
        triggerEvent("Silence Boss")
    end
end

-- Run code when internal event of the SMBX Engine has been triggered
-- eventName - name of triggered event
function onEvent(eventName)
    if eventName == "Egg Time" then
        triggerEvent("Move Up Blocks")
        triggerEvent("Move Down Blocks 2")
    end
end

function onNPCKill(eventObj, npcObj, npcKillReason) 
	if npcObj.id == 15 then 
		globalsave.OpenCastle = true
	elseif npcObj.id == 97 and npcKillReason == 9 then
		Text.showMessageBox("Peach's Castle has been re-opened!")
	end
end


-- globalsave.OpenCastle